package com.gemme.gemme.wode;

import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.gemme.gemme.BaseActivity;
import com.gemme.gemme.R;
import com.gemme.gemme.util.DpUtil;
import com.gemme.gemme.util.ShapeUtil;
import com.gemme.gemme.view.Topview;
import com.google.android.material.tabs.TabLayout;
import com.jaeger.library.StatusBarUtil;
import com.yanzhenjie.recyclerview.SwipeRecyclerView;

import java.util.ArrayList;

//侧滑删除地址
public class PlatformMoneyActivity extends BaseActivity{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_platform_money);
        initTop();
        initView();
        initTab();
    }


    PlatformAdapter adapter;
    ArrayList<String> mDataList = new ArrayList<>();
    private void initView() {
        SwipeRecyclerView recyclerView = findViewById(R.id.rvResult);

        mDataList.add("1");
        mDataList.add("2");
        mDataList.add("3");
        mDataList.add("4");
       /* DefaultItemDecoration mItemDecoration = new DefaultItemDecoration(ContextCompat.getColor
                (this, R.color.divider_color));
        recyclerView.addItemDecoration(mItemDecoration);*/
        LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);
        recyclerView.setLayoutManager(mLayoutManager);
//        recyclerView.setLongPressDragEnabled(false); // 拖拽排序，默认关闭。
        adapter = new PlatformAdapter();
        recyclerView.setAdapter(adapter);
        adapter.notifyDataSetChanged(mDataList);


    }


    private void initTab() {
         String[] titles = new String[]{"全部","收入","支出"};
        TabLayout tablayout = findViewById(R.id.tablayout);
        tablayout.addTab(tablayout.newTab());
        tablayout.addTab(tablayout.newTab());
        tablayout.addTab(tablayout.newTab());
        for(int i=0;i<titles.length;i++){
            tablayout.getTabAt(i).setText(titles[i]);
        }

        tablayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                System.out.println();
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {
                System.out.println();
            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {
                System.out.println();
            }
        });
    }

    private void initTop() {
//        StatusBarUtil.setColor(this,getResources().getColor(R.color.white_color) );
        StatusBarUtil.setTransparent(this);
//        StatusBarUtil.setTranslucent(this,250);
        Topview topview = findViewById(R.id.topview);
        topview.setContentText("平台币");
    }



    public class PlatformAdapter extends RecyclerView.Adapter<PlatformAdapter.ViewHolder>{


        private ArrayList<String> mDataList;

        @NonNull
        @Override
        public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
            //adapter_address
            View inflate = LayoutInflater.from(viewGroup.getContext()).
                    inflate(R.layout.platform_item, null);
            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
            inflate.setLayoutParams(layoutParams);
            return new PlatformAdapter.ViewHolder(inflate);
        }

        @Override
        public void onBindViewHolder(@NonNull ViewHolder holder, int position) {

        }

        @Override
        public int getItemCount() {
            return mDataList.size();
        }

        public void notifyDataSetChanged(ArrayList<String> mDataList) {

            this.mDataList = mDataList;
        }

        public class ViewHolder extends RecyclerView.ViewHolder {
            public ViewHolder(@NonNull View itemView) {
                super(itemView);

                TextView tv_vip = itemView.findViewById(R.id.tv_vip);
                tv_vip.setBackground(ShapeUtil.getCornBg(DpUtil.dp2px(mContext,9),"#FF403F3F"));
            }
       }
    }

}